<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>this,call,apply</title>
</head>
<script>
    function test() {
        console.log(this);
    }
    function test2() {
        test();
    }
    function test3() {
        this.a = 21;
        console.log(this);
        this.test2 = function () {
            console.log(this);
        };
    }
    test();
    test2();
    test.call({ a: 1 })
    var a = new test3()
    a.test2();

    var obj = {
        fire: function () {
            function innerFire() {
                console.log(this === window)
            }
            console.log(this);
            innerFire();   // 独立函数调用
        }
    }
    obj.fire(); //输出 true

    function fib(n) {
        if (n < 2)
            return n;
        else
            return fib(n - 2) + fib(n - 1);
    }
    var N = 40;
    var start = new Date().getTime();
    document.write("计算结果：" + fib(N) + "</br>");
    var end = new Date().getTime();
    document.write("计算" + N + "个斐波那契数列耗时：" + (end - start) / 1000.0 + "秒");
</script>

<body>

</body>

</html>